package com.hualan.controller;

import com.hualan.pojo.PageResult;
import com.hualan.pojo.PsyKnowledge;
import com.hualan.pojo.Result;
import com.hualan.service.PsyKnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/psyknowledge")
public class PsyKnowledgeController {
    @Autowired
    private PsyKnowledgeService psyKnowledgeService;

    @GetMapping("/search")
    public Result queryAllPsyKnowledge(String title,@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer pageSize) {
        PageResult pageResult = psyKnowledgeService.queryAllPsyKnowledge(title, page, pageSize);
        return Result.success(pageResult);
    }

    @PostMapping("/add")
    public Result addPsyKnowledge(@RequestBody PsyKnowledge psyKnowledge) {
        return psyKnowledgeService.addPsyKnowledge(psyKnowledge);
    }

    @PutMapping("/update")
    public Result updatePsyKnowledge(@RequestBody PsyKnowledge psyKnowledge) {
        return psyKnowledgeService.updatePsyKnowledge(psyKnowledge);
    }

    @PutMapping("/delete")
    public Result deletePsyKnowledge(@RequestBody List<Integer> ids) {
        return psyKnowledgeService.deletePsyKnowledge(ids);
    }
}
